import {post, get} from "./http";

//注册
export const SignUp =(params) =>post('/consumer/add',params)
//登录
export const LoginIn =(params) =>post('/consumer/login',params)
//修改密码
export const updatePwd = (payload) => post(`/consumer/updatePassword`, payload)
// 上传用户头像
export const uploadAvatar = (payload) => post(`consumer/upload`, payload, {
  headers: {'Content-Type': 'multipart/form-data'}, cache: false,
  contentType: false,
  processData: false,
})
//根据用户id查询该用户的详细信息
export const getConsumerOfId = (id) =>get(`/consumer/detail?id=${id}`);

//根据用户id查找自己上传的歌曲
export const songOfConsumerId = (pageNum, pageSize, name, consumerId) => get(`/staff/page`, {
  pageNum,
  pageSize,
  name,
  consumerId
})

export const selectUpdateStaffByConsumerId = (pageNum, pageSize, consumerId) => get(`/staff/selectUpdateStaffByConsumerId`, {
  pageNum,
  pageSize,
  consumerId
})



/**
 *  乐谱
 *
 */
//查询最新乐谱
export const getNewStaff = () => post(`/staff/new`)
//查询最热乐谱
export const getHotStaff = () => post(`/staff/hot`)
//模糊查询乐谱名
export const LikeStaffName = (keywords) => get(`/staff/likeStaffName?name=${keywords}`)
//根据乐谱集id查询乐谱列表
export const listStaffDetail = (staffListId) => get(`staff/staffs?staffListId=${staffListId}`)
//根据乐谱id查询乐谱信息
export const getStaffById = (staffId) => get(`staff/selectByStaffIds?staffId=${staffId}`)
//下载加一
export const increDownloadStaffCount = (payload) => get(`staff/addViewCount`,payload)
//上传乐谱
export const uploadStaffFile = (payload) => post(`staff/uploads`,payload,{
  headers:{
    'content-type':'multipart/form-data'
  }
})
//用户重新上传乐谱
export const returnStaffFile = (staff) => post(`/staff/againUploads`, staff, {
      headers: {
        'content-type': 'multipart/form-data'
      }
    }
)




/**
 * 乐谱集
 *
 */
//查询所有乐谱集不分页
export const getAllStaffList = () => get('/staffListAll')
//查询所有的风格
export const getAllStaffStyle = () => get('/staffStyle')
//模糊查询乐谱集名
export const likeStaffListName = (keywords) => get(`/likeStaffListName?title=${keywords}`)
//根据风格查询乐谱集(乐谱集有数据)
export const StaffListStyle = (style) => get(`/staffListStyle?style=${style}`)
//根据风格查询乐谱集
export const StaffListStyleAll = (style) => get(`/staffListStyleAll?style=${style}`)

/**
 * 评论
 */

//提交评论
export const setComment = (params) => post('/comment/addComment',params);
//返回当前乐谱集或乐谱的评价列表
export const getAllComment = (type,id) =>{
  if (type == 0){
    //查询乐谱的所有评论
    return get(`comment/commentOfStaffId?staffId=${id}`)
  }else {
    //查询乐谱集的所有评论
    return get(`/comment/commentOfStaffListId?staffListId=${id}`)
  }
}

/**
 * 收藏
 */

//新增收藏
export const setCollect = (params) => post('/collect/addCollect',params);
// 删除收藏
export const deleteCollect = (params)=>get('/collect/delete',params)
//指定用户的收藏列表
export const getCollectOfConsumerId = (consumerId) =>get(`/collect/collectOfConsumerId?consumerId=${consumerId}`)
//收藏列表根据用户id查询
export const getCollectOfStaff = (consumerId) =>get(`/staff/likeStaff?consumerId=${consumerId}`)
// 用户是否收藏该乐谱
export const isCollectOfStaff = (params)=>get('/collect/isCollectOfStaff',params)










